package com.sh.限流算法.漏桶算法;

public class LeakyBucketLimiterTest {
    public static void main(String[] args) {
        LeakyBucketLimiter limiter = new LeakyBucketLimiter(100, 10);

        System.out.println("Testing leaky bucket limiter:");
        for (int i = 0; i < 1150; i++) {
            boolean allowed = limiter.limit();
            System.out.println("请求 " + (i + 1) + " 通过吗 " + allowed);
            try {
                Thread.sleep(50);
            } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
            }
        }
    }
}
